//
//  UIBarButton_extension.swift
//  我的微博
//
//  Created by shmily on 15/8/6.
//  Copyright © 2015年 Stanford-IOS8-Swift-shmilyAshen. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    
    convenience init(pictureName: String,targrt: AnyObject?,action: Selector?) {
        let btn = UIButton()
        btn.setImage(UIImage(named: pictureName), forState: UIControlState.Normal)
        btn.setImage(UIImage(named: pictureName + "_highlighted"), forState: UIControlState.Highlighted)
        if let actionName = action {
            btn.addTarget(targrt, action: actionName, forControlEvents: UIControlEvents.TouchUpInside)
        }
        btn.sizeToFit()
        self.init(customView:btn)
    }
    
}
